package cn.iocoder.yudao.module.design.dal.mysql.house;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.house.vo.HouseBaseVO;
import cn.iocoder.yudao.module.design.controller.admin.house.vo.HouseExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.house.vo.HousePageReqVO;
import cn.iocoder.yudao.module.design.dal.dataobject.house.HouseDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 装修的房子信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface HouseMapper extends BaseMapperX<HouseDO> {

    default PageResult<HouseDO> selectPage(HousePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HouseDO>()
                .inIfPresent(HouseDO::getId,reqVO.getIds())
                .eqIfPresent(HouseDO::getOwnerId, reqVO.getOwnerId())
                .eqIfPresent(HouseDO::getAddress, reqVO.getAddress())
                .eqIfPresent(HouseDO::getArea, reqVO.getArea())
                .eqIfPresent(HouseDO::getStyle, reqVO.getStyle())
                .eqIfPresent(HouseDO::getBudget, reqVO.getBudget())
                .eqIfPresent(HouseDO::getDesignerId, reqVO.getDesignerId())
                .eqIfPresent(HouseDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(HouseDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(HouseDO::getRemark, reqVO.getRemark())
                .likeIfPresent(HouseDO::getProjectName, reqVO.getProjectName())
                .orderByDesc(HouseDO::getCreateTime)
        );
    }

    default List<HouseDO> selectList(HouseExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<HouseDO>()
                .eqIfPresent(HouseDO::getOwnerId, reqVO.getOwnerId())
                .eqIfPresent(HouseDO::getAddress, reqVO.getAddress())
                .eqIfPresent(HouseDO::getArea, reqVO.getArea())
                .eqIfPresent(HouseDO::getStyle, reqVO.getStyle())
                .eqIfPresent(HouseDO::getBudget, reqVO.getBudget())
                .eqIfPresent(HouseDO::getDesignerId, reqVO.getDesignerId())
                .eqIfPresent(HouseDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(HouseDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(HouseDO::getRemark, reqVO.getRemark())
                .orderByDesc(HouseDO::getId));
    }

    default List<HouseDO> selectList(HouseBaseVO reqVO) {
        return selectList(new LambdaQueryWrapperX<HouseDO>()
                .eqIfPresent(HouseDO::getOwnerId, reqVO.getOwnerId())
                .eqIfPresent(HouseDO::getAddress, reqVO.getAddress())
                .eqIfPresent(HouseDO::getArea, reqVO.getArea())
                .eqIfPresent(HouseDO::getStyle, reqVO.getStyle())
                .eqIfPresent(HouseDO::getBudget, reqVO.getBudget())
                .eqIfPresent(HouseDO::getDesignerId, reqVO.getDesignerId())
                .eqIfPresent(HouseDO::getStatus, reqVO.getStatus())
                .eqIfPresent(HouseDO::getRemark, reqVO.getRemark())
                .orderByDesc(HouseDO::getId));
    }
    default List<HouseDO> selectListByStatus(Integer status) {
        return selectList(HouseDO::getStatus, status);
    }



}
